<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        str="011010"
    var nums=str.split("");
        var length=nums.length;

        for(var i=length-1;i>0;i-2){
            if(nums[i]==1){
                var temp=nums.pop();
                nums.unshift(temp);
                
            }else break;
        }
        console.log(nums);
        var findLongestOne=function(nums){
            console.log("max");
            var max=0;
            var sum=0;
            for(var i=0;i<length;i++){
                if(nums[i]==1){
                    sum+=1;
                }else{sum=0;}
                if(max<sum)
                {
                    max=sum;
                }
            }
             
             return max;
        }
        console.log(findLongestOne(nums));
    </script>
</body>
</html>